DISCUSSION
The
ATSUMatchFontsToText function obtains the first subrange of text whose character(s) cannot be drawn with the assigned font and recommends a substitute font. It does not actually perform font substitutions. If you want ATSUI to perform font substitutions, call the function
ATSUSetTransientFontMatching.
ATSUMatchFontsToText scans all valid fonts on the user's system for a substitute font. This is the default search behavior used if you do not call the function
ATSUSetFontFallbacks, or if you pass the constant
kATSUDefaultFontFallbacks in the
iFontFallbackMethod parameter of the function.
ATSUMatchFontsToText looks for characters in a specified range of text that cannot be drawn with the fonts in the style run. It passes back an offset to the first range of text that could not be drawn and suggests an alternative font to use. For example, if the subrange of text for which you wanted to perform font substitution was the text "abcde", and the characters `c' and `d' could not be drawn with the current font (that is, the font in the styles for this text layout object) but could be drawn with font F, and the character `e' could either be drawn with the current font or could not be drawn with font F, then
ATSUMatchFontsToText will pass back the
ATSUIFontID of font F in the
oFont parameter and will set
oChangedOffset to 2 and
oChangedLength to 2.
If the function returns the result codes
kATSUFontsMatched or
kATSUFontsNotMatched, you should update the input range and call
ATSUMatchFontsToText again to make sure that all the characters in the range could be drawn.